//
//  SNOtherChartBaseVc.m
//  project
//
//  Created by 黄建华 on 2017/12/9.
//  Copyright © 2017年 黄建华. All rights reserved.
//

#import "SNOtherChartBaseVc.h"
#import "SNOtherChartSelectTypeView.h"

@interface SNOtherChartBaseVc ()
@property (nonatomic, strong) SNOtherChartSelectTypeView *selectTypeView;
@end

@implementation SNOtherChartBaseVc

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    _selectTypeView = [[SNOtherChartSelectTypeView alloc] initWithFrame:SNFRAME((HHHWIDTH - 210)/2.0, 33 + 5 + FitSimpleIpx(0, 20), 210, 27)];
    _selectTypeView.center = CGPointMake(self.view.centerX, self.leftButton.centerY);
    [self.view addSubview:_selectTypeView];
    
    DEF_WEAKSELF_(SNOtherChartBaseVc)
    
    _selectTypeView.selectType = ^(SelectDateType type) {
        [weakSelf selectType:type];
    };
    
    UIButton *stepDetailButton = [UIButton buttonWithType:UIButtonTypeCustom];
    stepDetailButton.frame = SNFRAME(5, 30 + FitSimpleIpx(0, 20), 50, 50);
    [stepDetailButton setImageNormal:@"进入"];
    stepDetailButton.center = CGPointMake(25, self.leftButton.centerY);
    [stepDetailButton addTarget:self
                         action:@selector(backView)
               forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:stepDetailButton];
    
    UIButton *shareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    shareBtn.frame = CGRectMake(screenWidth - 80, 35, 44, 44);
    [shareBtn setImageNormal:@"分享share"];
    shareBtn.center = CGPointMake(HHHWIDTH - 22-10, self.leftButton.centerY);
    [shareBtn addTarget:self
                 action:@selector(shareButtonClick)
       forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:shareBtn];
    
//    SNShadowView *shadowLine = [[SNShadowView alloc] init];
//    shadowLine.frame = SNFRAME(0,20+FitSimpleIpx(0, 20) + 44, HHHWIDTH, 0);
//    [shadowLine showWithType:1];
//    [self.view addSubview:shadowLine];
    UIImageView *shadowLine = [[UIImageView alloc] init];
    shadowLine.frame = SNFRAME(0, 20+FitSimpleIpx(0, 20) + 44 -2, HHHWIDTH, 2);
    shadowLine.image = [UIImage image:@"lineImage"];
    [self.view addSubview:shadowLine];
}

// 分享
- (void)shareButtonClick {
    UIGraphicsBeginImageContext(CGSizeMake(screenWidth, screenHeight));
    
    [[UIApplication sharedApplication].delegate.window.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    NSMutableArray *items = [[NSMutableArray alloc] init];
    [items addObject:image];
    
    UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil];
    NSMutableArray           *excludedActivityTypes  = [NSMutableArray arrayWithArray:@[
                                                                                        UIActivityTypeMessage, UIActivityTypeMail, UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll, UIActivityTypeAddToReadingList, UIActivityTypePostToFlickr, UIActivityTypePostToVimeo, UIActivityTypePostToTencentWeibo, UIActivityTypeAirDrop,
                                                                                        UIActivityTypeOpenInIBooks]];
    activityViewController.excludedActivityTypes = excludedActivityTypes;
    
    [self presentViewController:activityViewController animated:YES completion:nil];
    activityViewController.completionWithItemsHandler = ^(UIActivityType __nullable activityType, BOOL completed, NSArray *__nullable returnedItems, NSError *__nullable activityError){
    };
}

- (void)backView {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)selectType:(SelectDateType)type {
    //    NSLog(@"周月年选择了>>>>>>%d",type);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end

